package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级相关接口")
public class NursingLevelController extends BaseController{

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult<List<NursingLevelVo>> findAll(){
        return success(nursingLevelService.findAll());
    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto dto){
        nursingLevelService.addNursingLevel(dto);
        return success();
    }

    @GetMapping("/listByPage")
    @ApiOperation("条件分页查询所有护理等级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "护理等级名称"),
            @ApiImplicitParam(name = "pageNum",value = "当前页码",defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",defaultValue = "5"),
            @ApiImplicitParam(name = "status",value = "状态(0:禁用,1:启用)")
    })
    public ResponseResult findPage(String name,Integer pageNum,Integer pageSize,Integer status){
        PageResponse response = nursingLevelService.findPage(name,pageNum,pageSize,status);
        return success(response);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult findById(@PathVariable Long id){
        NursingLevelVo vo = nursingLevelService.findById(id);
        return success(vo);
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult enableOrDisable(
            @ApiParam(value = "等级ID", required = true) @PathVariable Long id,
            @ApiParam(value = "状态", required = true) @PathVariable Integer status) {
        nursingLevelService.enableOrDisable(id, status);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deleteLevel(@PathVariable Long id) {
        nursingLevelService.deleteLevel(id);
        return success();
    }

    @PutMapping("/update")
    @ApiOperation("编辑护理项目")
    public ResponseResult updateLevel(@RequestBody NursingLevelDto dto){
        nursingLevelService.updateLevel(dto);
        return success();
    }
}
